package com.catmiw.swt;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Properties;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

import com.catmiw.wyz.util.ExcelUtils;

public class DialogAddEnglishWordPhrase extends BasicDialog implements NetFileGetter {
	public DialogAddEnglishWordPhrase(Shell parent) {
		super(parent);
		rowposition = new int[] { 14, 8, 68, 10 };
		columnposition = new int[] { 100 };
	}

	static String LINE_SEPARATOR=System.getProperty("line.separator");
	
	static String[] PART_OF_SPEECH = { "ABBREVIATION","ADJ", "ADV", "AUX", "COLOUR", "COMB",
			"CONJ","CONJ-COORD","CONJ-SUBORD", "CONVENTION", "DET","DET-POSS", "EXCLAM", "FRACTION", "LINK", "MODAL",
			"N-COUNT", "N-COUNT-COLL", "N-FAMILY", "N-IN-NAMES", "N-MASS","N-PLACE",
			"N-PLURAL", "N-PROPER", "N-PROPER-COLL", "N-PROPER-PLURAL",
			"N-SING", "N-SING-COLL", "N-TITLE", "N-UNCOUNT", "N-UNCOUNT-COLL",
			"N-VAR", "N-VAR-COLL", "N-VOC", "NEG", "NUM", "ORD", "PASSIVE",
			"PHRASAL VERB", "PHRASE", "PREDET", "PREFIX", "PREP",
			"PREP-PHRASE", "PRON", "PRON-SING", "QUANT", "QUANT-PLURAL",
			"QUEST", "RECIP", "SOUND", "SUFFIX", "VERB", "V-LINK", "V-PASSIVE",
			"V-RECIP", "V-RECIP-PASSIVE","See also:" };
	static String[] PART_OF_SPEECH_CHINESE = {"ABBREVIATION,缩写", "ADJ,adjective 形容词",
			"ADV,adverb 副词", "AUX,auxiliary verb 助动词",
			"COLOUR,colour word 颜色词", "COMB,combining form 构词成分",
			"CONJ,conjunction 连词","CONJ-COORD","CONJ-SUBORD", "CONVENTION,convention 惯用语",
			"DET,determiner 限定词","DET-POSS", "EXCLAM,exclamation 感叹语",
			"FRACTION,fraction 分数词", "LINK,V-LINK 连系动词",
			"MODAL,modal verb 情态动词", "N-COUNT,count noun 可数名词",
			"N-COUNT-COLL,collective count noun 可数集合名词",
			"N-FAMILY,family noun 家庭成员名词", "N-IN-NAMES,noun in names 名称名词",
			"N-MASS,mass noun 物质名词", "N-PLACE,地名","N-PLURAL,plural noun 复数名词",
			"N-PROPER,proper noun 专有名词",
			"N-PROPER-COLL,collective proper noun 专有集合名词",
			"N-PROPER-PLURAL,plural proper noun 专有复数名词",
			"N-SING,singular noun 单数名词",
			"N-SING-COLL,collective singular noun 单数集合名词",
			"N-TITLE,title noun 头衔名词", "N-UNCOUNT,uncount noun 不可数名词",
			"N-UNCOUNT-COLL,collective uncount noun 不可数集合名词",
			"N-VAR,variable noun 可变名词",
			"N-VAR-COLL,collective variable noun 可变集合名词",
			"N-VOC,vocative noun 称呼名词", "NEG,negative 否定词", "NUM,number 数词",
			"ORD,ordinal 序数词", "PASSIVE,V-PASSIVE 被动动词",
			"PHRASAL VERB,phrasal verb 短语动词", "PHRASE,phrase 短语",
			"PREDET,predeterminer 前置限定词", "PREFIX,prefix 前缀",
			"PREP,preposition 介词", "PREP-PHRASE,phrasal preposition 短语介词",
			"PRON,pronoun 代词", "PRON-SING,pronoun single 代词单数",
			"QUANT,quantifier 数量词", "QUANT-PLURAL,plural quantifier 复数数量词",
			"QUEST,question word 疑问词", "RECIP,V-RECIP 相互动词",
			"SOUND,sound word 声音词", "SUFFIX,suffix 后缀", "VERB,verb 动词",
			"V-LINK,link verb 连系动词", "V-PASSIVE,passive verb 被动动词",
			"V-RECIP,reciprocal verb 相互动词",
			"V-RECIP-PASSIVE,passive reciprocal verb 被动相互动词",
			"See also:"};
	static String[] REQUIREMENT = { "三会", "四会"};
	static String ICBA_URL = "http://www.iciba.com/";
	static String ICBA_MP3_RESOURCE_UK = "http://res.iciba.com/resource/amp3/0/0/";
	static String ICBA_MP3_RESOURCE_US = "http://res.iciba.com/resource/amp3/1/0/";

	private Text txWord;
	private Combo cmBook;
	private Combo cmUnit;
	private Button btQuery;
	private Table tbTable;
	private Combo cmPartOfSpeech;
	private Text txMeaning;
	private Button[] btsRequirement;
	private Button btConfirm, btQuit;
	private Button btLoadWordList,btNext,btPrevious;

	private String keyword;
	
	private String[] books;
	private Integer[] units;

	private EnglishWordsXmlHandler xmlHandler;

	private int currentposition=-1;
	
	private String wordExcelFile;

	@Override
	public void setProperties(Properties properties) {
		this.properties = properties;
		xmlHandler = new EnglishWordsXmlHandler(
				properties.getProperty("英语单词文件名"));

		wordExcelFile=properties.getProperty("英语单词Excel文件名");

		String bk = properties.getProperty("英语课本");
		String[] tp = bk.split(",");
		books = new String[tp.length];
		units = new Integer[tp.length];

		for (int i = 0; i < tp.length; i++) {
			String str = tp[i];
			String[] tt = str.split("-");
			books[i] = tt[0];
			units[i] = Integer.parseInt(tt[1]);
		}
	}

	@Override
	public void createContents() {
		shell.setText("添加英语单词/短语");
		shell.setLayout(new FormLayout());

		Composite cp = new Composite(shell, SWT.BORDER);
		cp.setLayout(new FormLayout());
		setPosition(cp, 1, 1);

		Label lb = new Label(cp, SWT.NONE);
		lb.setText("单词/短语：");
		FormData formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(0, COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		lb.setLayoutData(formdata);

		txWord = new Text(cp, SWT.BORDER);
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(lb, 10);
		formdata.right = new FormAttachment(50, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		txWord.setLayoutData(formdata);

		btQuery = new Button(cp, SWT.PUSH);
		btQuery.setText("查询");
		btQuery.setEnabled(false);
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(txWord, 10);
		formdata.right = new FormAttachment(65, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		btQuery.setLayoutData(formdata);
		
		//btLoadWordList,btNext,btPrevious
		btLoadWordList= new Button(cp, SWT.PUSH);
		btLoadWordList.setText("加载生词表");
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(btQuery, 10);
		formdata.right = new FormAttachment(80, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		btLoadWordList.setLayoutData(formdata);
		
		btPrevious= new Button(cp, SWT.PUSH);
		btPrevious.setText("上一个");
		btPrevious.setEnabled(false);
		
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(btLoadWordList, 10);
		formdata.right = new FormAttachment(90, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		btPrevious.setLayoutData(formdata);
		
		btNext= new Button(cp, SWT.PUSH);
		btNext.setText("下一个");
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(btPrevious, 10);
		formdata.right = new FormAttachment(100, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(50, 0 - COMPOSITESPACE);
		btNext.setLayoutData(formdata);
		
		
		
		lb = new Label(cp, SWT.NONE);
		lb.setText("课本：");
		formdata = new FormData();
		formdata.top = new FormAttachment(50, COMPOSITESPACE);
		formdata.left = new FormAttachment(0, COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		lb.setLayoutData(formdata);

		cmBook = new Combo(cp, SWT.DROP_DOWN);
		for (String str : books) {
			cmBook.add(str);
		}

		formdata = new FormData();
		formdata.top = new FormAttachment(50, COMPOSITESPACE);
		formdata.left = new FormAttachment(lb, 10);
		formdata.right = new FormAttachment(50, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		cmBook.setLayoutData(formdata);

		lb = new Label(cp, SWT.NONE);
		lb.setText("单元：");
		formdata = new FormData();
		formdata.top = new FormAttachment(50, COMPOSITESPACE);
		formdata.left = new FormAttachment(cmBook, 10);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		lb.setLayoutData(formdata);

		cmUnit = new Combo(cp, SWT.DROP_DOWN);
		formdata = new FormData();
		formdata.top = new FormAttachment(50, COMPOSITESPACE);
		formdata.left = new FormAttachment(lb, 10);
		formdata.right = new FormAttachment(100, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		cmUnit.setLayoutData(formdata);

		cp = new Composite(shell, SWT.BORDER);
		cp.setLayout(new FormLayout());
		setPosition(cp, 2, 1);

		lb = new Label(cp, SWT.NONE);
		lb.setText("词性：");
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(0, COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		lb.setLayoutData(formdata);

		cmPartOfSpeech = new Combo(cp, SWT.DROP_DOWN);
		cmPartOfSpeech.setItems(PART_OF_SPEECH_CHINESE);
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(lb, 10);
		formdata.right = new FormAttachment(50, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(10, 0 - COMPOSITESPACE);
		cmPartOfSpeech.setLayoutData(formdata);

		lb = new Label(cp, SWT.NONE);
		lb.setText("词义：");
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(cmPartOfSpeech, 10);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		lb.setLayoutData(formdata);

		txMeaning = new Text(cp, SWT.BORDER);
		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(lb, 10);
		formdata.right = new FormAttachment(100, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		txMeaning.setLayoutData(formdata);

		tbTable = new Table(shell, SWT.BORDER | SWT.CHECK | SWT.MULTI
				| SWT.FULL_SELECTION);
		setPosition(tbTable, 3);
		tbTable.setLinesVisible(true);
		tbTable.setHeaderVisible(true);
		TableColumn tc = new TableColumn(tbTable, SWT.CENTER);
		tc.setText("");
		tc.setAlignment(SWT.CENTER);
		tc.setWidth(30);

		tc = new TableColumn(tbTable, SWT.CENTER);
		tc.setText("序号");
		tc.setAlignment(SWT.CENTER);
		tc.setWidth(40);

		tc = new TableColumn(tbTable, SWT.CENTER);
		tc.setAlignment(SWT.LEFT);
		tc.setText("词性");
		tc.setWidth(100);

		tc = new TableColumn(tbTable, SWT.CENTER);
		tc.setAlignment(SWT.LEFT);
		tc.setText("词义");
		tc.setWidth(295);

		tc = new TableColumn(tbTable, SWT.CENTER);
		tc.setAlignment(SWT.LEFT);
		tc.setText("英义");
		tc.setWidth(300);

		cp = new Composite(shell, SWT.NONE);
		cp.setLayout(new FormLayout());
		setPosition(cp, 4, 1);

		Group group = new Group(cp, SWT.SHADOW_ETCHED_OUT);
		group.setLayout(new FillLayout(SWT.HORIZONTAL));
		group.setText("学习要求");

		btsRequirement = new Button[REQUIREMENT.length];
		for (int i = 0; i < REQUIREMENT.length; i++) {
			btsRequirement[i] = new Button(group, SWT.RADIO);
			btsRequirement[i].setText(REQUIREMENT[i]);
		}

		formdata = new FormData();
		formdata.top = new FormAttachment(0, COMPOSITESPACE);
		formdata.left = new FormAttachment(0, COMPOSITESPACE);
		formdata.right = new FormAttachment(50, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		group.setLayoutData(formdata);

		btConfirm = new Button(cp, SWT.PUSH);
		btConfirm.setText("保存词义");
		btQuit = new Button(cp, SWT.PUSH);
		btQuit.setText("退出");

		formdata = new FormData();
		formdata.top = new FormAttachment(30, COMPOSITESPACE);
		formdata.left = new FormAttachment(80, COMPOSITESPACE);
		formdata.right = new FormAttachment(90, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		btConfirm.setLayoutData(formdata);

		formdata = new FormData();
		formdata.top = new FormAttachment(30, COMPOSITESPACE);
		formdata.left = new FormAttachment(btConfirm, COMPOSITESPACE);
		formdata.right = new FormAttachment(100, 0 - COMPOSITESPACE);
		formdata.bottom = new FormAttachment(100, 0 - COMPOSITESPACE);
		btQuit.setLayoutData(formdata);

		shell.setSize(800, 600);
		shell.setLocation(
				Display.getCurrent().getClientArea().width / 2
						- shell.getSize().x / 2,
				Display.getCurrent().getClientArea().height / 2
						- shell.getSize().y / 2);
	}

	private void queryWord() {
		if (keyword==null)
			return;
		
		tbTable.removeAll();

		Word word = xmlHandler.loadWord(keyword);

		if (word == null) {
			String mp3path=properties.getProperty("英语mp3文件夹");
			EnglishWordNetLoader loader=new EnglishWordNetLoader(keyword,mp3path,xmlHandler,this);
			new Thread(loader).run();
			return;
		} else {
			List<Meaning> meanings = word.getMeanings();
			Collections.sort(meanings, new Comparator<Meaning>() {
				public int compare(Meaning arg0, Meaning arg1) {
					int i0 = (arg0.getOrder() == null ? 0 : arg0.getOrder()
							.intValue());
					int i1 = (arg0.getOrder() == null ? 0 : arg0.getOrder()
							.intValue());
					return i0 - i1;
				}
			});
			for (Meaning m : word.getMeanings()) {
				TableItem ti = new TableItem(tbTable, SWT.NONE);
				ti.setText(1, "" + m.getOrder());
				ti.setText(2, m.getPartOfSpeech());
				ti.setText(3, m.getChinese()==null?"":m.getChinese());
				ti.setText(4, m.getEnglish()==null?"":m.getEnglish());
			}
		}

		for (NewWord sw : newwords) {
			if (sw.getWord().equals(keyword)) {
				if (null!=sw.getMeans()&&!"".equals(sw.getMeans())){
					String[] tt=sw.getMeans().split(",");
					for (String t:tt){
						int order=Integer.parseInt(t);
						tbTable.getItem(order - 1).setChecked(true);
					}
				}
			}
		}

		if (tbTable.getItemCount() > 0) {
			txMeaning.setEnabled(false);
			txMeaning.setText("");
			cmPartOfSpeech.setEnabled(false);
			cmPartOfSpeech.setText("");
		} else {
			txMeaning.setEnabled(true);
			cmPartOfSpeech.setEnabled(true);
		}
	}

	public void saveStudyWord() {
		if (this.currentposition<0){
			messagebox("提示", "请先加载生词表!");
			return;
		}
		NewWord nw=newwords.get(this.currentposition);
		if (!nw.getWord().equals(keyword)){
			messagebox("提示", "请先加载生词表!");
			return;
		}
		
		String means="";
		
		if (tbTable.getItemCount() == 0) {
			Word word = new Word();
			word.setId(keyword);
			if ("".equals(txMeaning.getText().trim())) {
				messagebox("提示", "请输入中文意思!");
				return;
			}
			if ("".equals(cmPartOfSpeech.getText().trim())) {
				messagebox("提示", "请选择词性!");
				return;
			}
			List<Meaning> meanings = new ArrayList<Meaning>();
			Meaning m = new Meaning();
			m.setOrder(1);
			m.setChinese(txMeaning.getText().trim());
			m.setEnglish("");
			m.setPartOfSpeech(cmPartOfSpeech.getText().trim());
			meanings.add(m);
			word.setMeanings(meanings);
			xmlHandler.storeWord(word);
			
			means="1";
		} else {
			for (int i = 0; i < tbTable.getItemCount(); i++) {
				TableItem ti = tbTable.getItem(i);
				if (ti.getChecked()) {
					means=means+(i+1)+",";
				}
			}
			if (means.endsWith(","))
				means=means.substring(0,means.length()-1);
		}
		
		Workbook wb=ExcelUtils.getWorkbook(wordExcelFile);
		Sheet sheet=wb.getSheet("单词");
		Row row=sheet.getRow(currentposition+1);
		Cell cell=row.getCell(2);
		if (cell==null||!keyword.equals(cell.getStringCellValue())){
			messagebox("提示", "保存生词[" + keyword + "]出错了！！");
			return;
		}
		cell=row.createCell(4);
		cell.setCellValue(means);
		ExcelUtils.writeWorkbook(wb, wordExcelFile);
		
		nw.setMeans(means);
		
		messagebox("提示", "保存生词[" + keyword + "]完成！");
	}

	@Override
	public void addListeners() {
		btQuery.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				keyword = txWord.getText().trim();
				if (!"".equals(keyword)) {
					queryWord();
				}
			}
		});

		btQuit.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				shell.dispose();
			}
		});

		btConfirm.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				saveStudyWord();
			}
		});

		cmBook.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				cmUnit.removeAll();
				int index = cmBook.getSelectionIndex();
				for (int i = 1; i <= units[index]; i++) {
					cmUnit.add("" + i);
				}
			}

			public void widgetDefaultSelected(SelectionEvent e) {
			}

		});

		btLoadWordList.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				loadNewWordList();
			}
		});

		btNext.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				nextWord(true);
			}
		});

		btPrevious.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				nextWord(false);
			}
		});

		//FileDialog
	}

	private void nextWord(boolean next){
		setNowWord();
	}

	/*
	public void loadNewWordList(){
		FileDialog fd=new FileDialog(shell,SWT.NONE);
		String str=fd.open();
		
		String content=null;
		try {
			content=FileUtils.readFileToString(new File(str), "GBK");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		String[] lines=content.split(LINE_SEPARATOR);
		for (String line:lines){
			newwordlist.add(line);
		}
		currentposition=0;
		setNowWord();
	}
	*/
	
	private List<NewWord> newwords;
	
	public void loadNewWordList(){
		Workbook wb = ExcelUtils.getWorkbook(wordExcelFile);
		Sheet sheet = wb.getSheet("单词");
		
		newwords=new ArrayList<NewWord>();
		
		for (int i=1;i<65525;i++){
			Row row=sheet.getRow(i);
			if (row==null)
				break;
			Cell cell=row.getCell(2);
			if (cell==null)
				continue;
			String temp=cell.getStringCellValue();
			if (temp==null||"".equals(temp))
				continue;
			NewWord nw=new NewWord();
			nw.setWord(temp.trim());
			newwords.add(nw);
			
			cell=row.getCell(0);
			if (cell==null)
				continue;
			nw.setBook(cell.getStringCellValue());
			
			cell=row.getCell(1);
			if (cell==null)
				continue;
			nw.setUnit((int)(cell.getNumericCellValue()));
			
			cell=row.getCell(3);
			if (cell==null)
				continue;
			nw.setRequire((int)(cell.getNumericCellValue()));
			
			cell=row.getCell(4);
			if (cell==null)
				continue;
			nw.setMeans(cell.getStringCellValue());

		}

		currentposition=0;
		setNowWord();
	}
	
	public void setNowWord(){
		for (int i=currentposition;i<newwords.size();i++){
			NewWord w=newwords.get(i);
			if (null==w.getMeans()||"".equals(w.getMeans())){
				currentposition=i;
				keyword=w.getWord().trim();
				
				txWord.setText(keyword);
				cmBook.setText(w.getBook());
				cmUnit.setText(""+w.getUnit());
				if (w.getRequire()==3){
					btsRequirement[0].setSelection(true);
					btsRequirement[1].setSelection(false);
				} else if (w.getRequire()==4){
					btsRequirement[0].setSelection(false);
					btsRequirement[1].setSelection(true);
				}
				break;
			} else 
				continue;
		}
		
		queryWord();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);

		DialogAddEnglishWordPhrase iewp = new DialogAddEnglishWordPhrase(shell);
		Properties p = new Properties();
		try {
			p.load(new FileReader(
					"d:/studyassist/config/studyassist.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		iewp.setProperties(p);
		iewp.open();
	}

	public void afterLoad(boolean success) {
		if (success){
			this.queryWord();
		} else {
			cmPartOfSpeech.setEnabled(true);
			txMeaning.setEnabled(true);

			messagebox("提示","无法找到"+keyword+"的翻译，请自己输入");
		}
		
	}
}

//57/8e/578ed5a4eecf5a15803abdc49f6152d6.mp3
